package main

import (
	"ce-cloud-service/internal/define"
	proto "ce-cloud-service/internal/proto/base/user"
	"ce-cloud-service/internal/services/base/user/db/impl"
	"ce-cloud/pkg/log"
	"ce-cloud/pkg/service/p_go_micro"
)

func main() {
	svc := p_go_micro.NewService(
		define.NewService(
			p_go_micro.MicroServiceInfo{
				Name:       define.ServiceNameBaseUser,
				ServerType: p_go_micro.ConstServerTypeDefault,
			}))
	err := proto.RegisterUserHandler(svc.Server(), &UserService{})
	if err != nil {
		log.Errorf("register user handler err: %s", err.Error())
		return
	}
	initDBImpl()
	if err = svc.Run(); err != nil {
		log.Fatalf("service Run() error(%v)", err)
	}
}

func initDBImpl() {
	impl.AutoMigrate()
}
